package com.example.day2.mvvm.utils;

import android.content.Context;

import androidx.room.Room;


import com.example.day2.db.MyDataBase;
import com.example.day2.db.StoreVideoDap;
import com.example.day2.db.UserAccountDao;

public class DBUtils {
    private DBUtils(){}
    private static DBUtils dbUtils ;
    public static DBUtils getInstance(){
        if (dbUtils == null){
            synchronized (DBUtils.class){
                if (dbUtils == null){
                    dbUtils = new DBUtils();
                }
            }
        }
        return dbUtils;
    }
    private StoreVideoDap storeVideoDap;
    private UserAccountDao userAccountDao;
    public void init(Context context){
        MyDataBase myDataBase = Room.databaseBuilder(context, MyDataBase.class, "mydb.db")
                .allowMainThreadQueries()
                .build();
        storeVideoDap = myDataBase.getStoreVideoDao();
        userAccountDao = myDataBase.getUserAccountDao();
    }

    public StoreVideoDap getStoreVideoDap() {
        return storeVideoDap;
    }

    public UserAccountDao getUserAccountDao() {
        return userAccountDao;
    }
}
